/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
/* eslint-disable vars-on-top */
/** EasyWeb iframe v3.1.8 date:2020-05-04 License By http://easyweb.vip */
layui.config({ // common.js是配置layui扩展模块的目录，每个页面都需要引入
    'version': '318', // 更新组件缓存，设为true不缓存，也可以设一个固定值
    // eslint-disable-next-line no-use-before-define
    'base': getProjectUrl() + 'assets/module/'
}).extend({
    'steps': 'steps/steps',
    'notice': 'notice/notice',
    'cascader': 'cascader/cascader',
    'dropdown': 'dropdown/dropdown',
    'fileChoose': 'fileChoose/fileChoose',
    'Split': 'Split/Split',
    'Cropper': 'Cropper/Cropper',
    'tagsInput': 'tagsInput/tagsInput',
    'citypicker': 'city-picker/city-picker',
    'introJs': 'introJs/introJs',
    'zTree': 'zTree/zTree'
}).use(['layer', 'admin'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var admin = layui.admin;

});

/** 获取当前项目的根路径，通过获取layui.js全路径截取assets之前的地址 */
function getProjectUrl() {
    let layuiDir = layui.cache.dir;
    if (!layuiDir) {
        let js = document.scripts,
            last = js.length - 1,
            src;
        for (let i = last; i > 0; i--) {
            if (js[i].readyState === 'interactive') {
                src = js[i].src;
                break;
            }
        }
        let jsPath = src || js[last].src;
        console.log(jsPath)
        layuiDir = jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
        // alert("ddd"+layuiDir)

    }
    return layuiDir.substring(0, layuiDir.indexOf('assets'));
}